package com.orangelife.mobile.housepurchasing.adapter;
 import android.content.Context;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.WindowManager;
 import android.widget.BaseAdapter;
 import android.widget.ImageView;
 import android.widget.LinearLayout;

 import com.curry.orangelife.mobile.R;
 import com.nostra13.universalimageloader.core.ImageLoader;
 import com.orangelife.mobile.util.BaseViewHolder;

 import java.util.List;

/**
 * Created by Administrator on 2016/5/26.
 */
public class ImageAdapter extends BaseAdapter {

    private Context mContext;
    List<String> list=null;

    public ImageAdapter(Context context, List<String> list){
        this.mContext=context;
        this.list=list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_comm_image, null);
        }
        ImageView ivComm = BaseViewHolder.get(convertView, R.id.iv_comm_iamge);
        WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        int width = wm.getDefaultDisplay().getWidth();
        int height = width * 9 / 16;
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height);
        ivComm.setLayoutParams(params);
        ImageLoader.getInstance().displayImage(list.get(position), ivComm );
        return convertView;
    }
}
